﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Media.Imaging;
using PersonaLibrary.Data;
using PersonaLibrary.View.EmploeeView;

namespace PersonaLibrary.Commands.LoadWithCommands
{
	internal sealed class ShowFullFoto : CommandBase
	{
		public override bool CanExecute(object parameter)
		{
			return parameter is Employee;
		}

		public override void Execute(object parameter)
		{
			Employee employee = (Employee)parameter;

			if (employee.Foto != null)
			{
				ShowFoto foto = new ShowFoto {DataContext = employee};

				foto.ShowDialog();
			}
			else
			{
				if(employee.Id != 0)
					EditCommands.Commands.LoadImage.Execute(employee.Id);
			}
		}
	}
}
